package com.huawei.appgallery.agwebview.view;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.TextView;
import com.huawei.appgallery.agwebview.api.ui.IWebViewFragmentProtocol;
import com.huawei.appgallery.foundation.ui.framework.uikit.ContractFragment;
import com.huawei.appmarket.framework.widget.RenderButton;
import com.huawei.hmf.annotation.FragmentDefine;
import o.azb;
import o.azf.a;
import o.azf.d;
import o.azf.j;
import o.azh;
import o.azq;
import o.bam;
import o.ciy;
import o.dof;
import o.fjm;

@FragmentDefine(alias = "webview_fragment", protocol = IWebViewFragmentProtocol.class)
public class WebViewFragment extends ContractFragment implements ciy {
    private fjm ʽ = fjm.ॱ(this);
    private boolean ˊ = false;
    private ViewGroup ˋ;
    protected WebView ˎ;
    protected azq ˏ = null;
    private Activity ॱ = null;
    private IWebViewFragmentProtocol ॱॱ;

    public void ˏ(Bundle bundle) {
        super.ˏ(bundle);
        this.ॱ = ॱˋ();
        this.ॱॱ = (IWebViewFragmentProtocol) this.ʽ.ॱ();
        if (this.ॱॱ == null) {
            azh.ˏ.ˊ("WebViewFragment", "fragmentProtocol is null");
        } else if (dof.ˋ(this.ॱॱ.getUrl())) {
            azh.ˏ.ˊ("WebViewFragment", "url is null");
        } else {
            this.ˏ = bam.INSTANCE.ˋ(ʽᐝ());
            if (this.ˏ == null) {
                azh.ˏ.ˊ("WebViewFragment", "webviewDelegate is null");
            } else if (this.ˏ.ˊ(ॱˋ(), this.ॱॱ)) {
                this.ˊ = true;
            }
        }
    }

    protected String ʽᐝ() {
        return "fragment_webview";
    }

    public View ˋ(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        if (this.ˋ == null) {
            this.ˋ = (ViewGroup) layoutInflater.inflate(d.ˏ, viewGroup, false);
            this.ˎ = (WebView) this.ˋ.findViewById(a.ॱ);
            azb.ˏ(this.ˎ);
            azb.ˏ(this.ˋ, a.ˊ);
            if (this.ˊ) {
                this.ˏ.ॱ(this.ॱ, this.ॱॱ);
                this.ˏ.ˎ(this.ˋ);
                this.ˏ.ˏ(this.ॱ, this.ॱॱ);
                ʼᐝ();
            } else {
                ˎ(this.ˋ);
            }
        }
        return this.ˋ;
    }

    private void ˎ(ViewGroup viewGroup) {
        if (this.ˎ != null) {
            this.ˎ.setVisibility(8);
            View findViewById = viewGroup.findViewById(a.ʾ);
            azb.ˏ(findViewById);
            RenderButton renderButton = (RenderButton) findViewById.findViewById(a.ॱˊ);
            ((TextView) findViewById.findViewById(a.ॱᐝ)).setText(j.ˊ);
            renderButton.setVisibility(8);
            findViewById.setVisibility(0);
        }
    }

    protected void ʼᐝ() {
        this.ˏ.ʽ(this.ॱॱ.getUrl());
    }

    public void ˌ() {
        super.ˌ();
        if (this.ˏ != null) {
            this.ˏ.ॱˋ();
        }
    }

    public void ˋᐝ() {
        super.ˋᐝ();
        if (this.ˏ != null) {
            this.ˏ.ˈ();
        }
    }

    public void ˎˎ() {
        this.ˋ = null;
        if (this.ˏ != null) {
            this.ˏ.ʽ();
        }
        super.ˎˎ();
    }

    public void ˋ(int i) {
    }

    public void ʽˊ() {
    }

    public void ʾॱ() {
        if (this.ˎ != null) {
            this.ˎ.post(new Runnable(this) {
                final /* synthetic */ WebViewFragment ˋ;

                {
                    this.ˋ = r1;
                }

                public void run() {
                    if (this.ˋ.ˎ != null) {
                        this.ˋ.ˎ.scrollTo(0, 0);
                    }
                }
            });
        }
    }
}
